package routes

import (
	"context"
	"fmt"
	"io/fs"
	"os"
	"wails/modules/editor/models"
)

func (this *Http) Do新建修正(ctx context.Context, args *Do新建修正参数, result *Do新建修正响应) (err error) {

	文件内容 := fmt.Sprintf(`import {cachex, IModify} from "db://assets/core/libs";

class Modify implements IModify {
    length(ctx: any, origin: number): number {
        return 0;
    }

    valid(ctx: any, field: string): boolean {
        return false;
    }

    value(ctx: any, field: string, origin: any, item0?: any): any {
    }

}

cachex.registerModify("%v", "%v", new Modify());`, args.P配置编号, args.Z字段路径)

	文件路径 := models.Module.Get脚本路径() + fmt.Sprintf(`/%v$%v$%v.ts`, args.P配置分类, args.Z字段路径, args.P配置编号)
	err = os.WriteFile(文件路径, []byte(文件内容), fs.ModePerm)
	if err != nil {
		return
	}

	return
}
